<?php
defined('BASEPATH') or exit('No direct script access allowed');

if (! function_exists('formCheck')) {

    function formCheck($config)
    {
        $CI = & get_instance();
        $CI->load->library('form_validation');
        $CI->form_validation->set_rules($config);
        $pattern="/<p>(.*)<\/p>/";
        if ($CI->form_validation->run() === false) {
            $error = validation_errors();
            preg_match_all($pattern, $error,$match);
            return $match[1];
        } else {
            return true;
        }
    }
}